package com.mall.live.controller;

import com.mall.common.response.CommonResponse;
import com.mall.live.service.ILiveFollowerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 关注，点赞
 * @author  LiJinYang
 * @email  283006176@qq.com
 * @date 2021/07/30 15:26
 * @version 1.0
 */
@RestController
@RequestMapping("/liveFollower")
public class LiveFollowerController {

    @Autowired
    private ILiveFollowerService iLiveFollowerService;

    /**
     * 关注主播
     * @param id
     * @param uid
     * @param image
     * @return
     */
    @GetMapping("/attention")
    public CommonResponse attention(Long id, Long uid, String image){
        try{
            iLiveFollowerService.attention(id,uid,image);
            return new CommonResponse(0,"关注成功");
        }catch (Exception e){
            e.printStackTrace();
            return new CommonResponse(-1,"关注失败");
        }
    }

    /**
     * 点赞
     * @param id
     * @param num
     * @return
     */
    @GetMapping("/like")
    public CommonResponse like(Long id,Integer num){
        try{
            iLiveFollowerService.like(id,num);
            return new CommonResponse(0,"点赞成功");
        }catch (Exception e){
            e.printStackTrace();
            return new CommonResponse(-1,"点赞失败");
        }
    }

}
